package com.magic.java8.methodref;

import org.junit.Test;

import java.util.Comparator;
import java.util.function.Consumer;
import java.util.function.Supplier;

/**
 * @author laoma
 * @create 2021-03-30 22:53
 */

public class TestMethod {

    @Test
    public void test1(){
        Consumer<String> con = System.out::println;
        con.accept("北京");
    }

    @Test
    public void test2(){
        Employee employee = new Employee(1001,"tom",12,5460);
        Supplier<String> supplier = ()->{
            return employee.getName();
        };
        String s = supplier.get();
        System.out.println("s = " + s);

        Supplier<String> supplier2 = employee::getName;
        System.out.println("supplier2.get() = " + supplier2.get());
    }

    @Test
    public void test3(){
        Comparator<Integer> com = Integer::compare;
        int compare = com.compare(12, 21);
        System.out.println("compare = " + compare);
    }
}
